<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\BookSerach */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Books';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="book-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php//  echo $this->render('_search', ['model' => $searchModel]); ?>

<!--    <p>-->
<!--        --><?//= Html::a('Create Book', ['create'], ['class' => 'btn btn-success']) ?>
<!--    </p>-->
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'title',
            'create_time:datetime',
            'author',
            'category',
            'socure',
            [
                'label'=>'操作',
                'format'=>'raw',
                'value' => function($data){
                    if($data->is_state==0){
                        $url=\yii\helpers\Url::to(['book/zhua', 'id' => $data->id]);
                        return Html::a('抓取', $url, ['title' => '抓取']);
                    }else{
                        $url=\yii\helpers\Url::to(['bookarticle/index', 'id' => $data->id]);
                        return Html::a('观看', $url, ['title' => '观看']);
                    }


                }
            ],
        ],
    ]); ?>
</div>
